/**
 * 图片模型
 */
import Base from './base.js'
import Paging from '../static/js/paging.js'
class Product extends Base{
    constructor() {
    	super();
    }
	/**
	 * 商品列表
	 */
	static getProduct(data={}) {
		return new Paging({
			url:'index/get_product',
			data:data
		})
	}
	// 商品详情
	static async getProductDetail(id){
		return await Base.request({
			url:'index/get_product_detail',
			data:{
				id:id 
			}
		  }) 
	}
	//商品收藏
	static async productCollection(id){
		return await Base.request({
			url:'index/product_collection',
			data:{
				id:id 
			},
			method:'POST',
			data_status:true
		  }) 
	}
	
	//当前选择商品的详情
	static skuStr(that){
		if(that.info.specs_status == 1){
			that.sku_str = '';
			for(var i=0;i<that.sku.length;i++){
				that.sku_str = that.sku_str + that.info.attrbute_list[i].name + '：';
				for(var j=0;j<that.info.attrbute_list[i].sub.length;j++){
					if(that.sku[i] == that.info.attrbute_list[i].sub[j].id){
						that.sku_str = that.sku_str + that.info.attrbute_list[i].sub[j].name + '，';
					}
				} 
			}
		}
	};
	/**
	 * 收藏商品
	 */
	static getCollection() {
		return new Paging({
			url:'auth/get_collection'
		})
	}
	/**
	 * 商品足迹
	 */
	static getFootprint() {
		return new Paging({
			url:'auth/get_footprint'
		})
	}
}
export default Product